import greenfoot.*;

/**
 * Class MyWorld: sample world to show how to make use of my world super-class SWorld
 */
public class MyWorld extends SWorld
{
    int jugX=0;
    public int lives = 100; //contador de las vidas del jugador
    public int nivel=3;
    /**
     * Creates a scrolling world using a main actor, a background, some obstacles, and a non-scrolling score.
     */
    public MyWorld()
    {    
        super(600, 600, 1, 5000,600); // scroll world constructor call; last parameter is scroll width
        // in the following statement, the main actor is placed in the center of the window
        setMainActor(new Rex(), 50, 100); // the int parameters are centered window x and y ranges
        // to start the main actor elsewhere
        mainActor.setLocation(-2100, 515);
        GreenfootImage bg = new GreenfootImage("Esenario3.jpg");
        addObject(new Score(), 550,10,false);
        addObject(new Lifes(), 40,80,false);
        addObject(new Ammo(), 40,100,false);
        addObject(new Vida(), 40,40,false);
        setScrollingBackground(bg); // set the scolling background image
        // add other scrollable objects normally
        addObject(new Ground(),200, 590);
        addObject(new barra(),-1880,450,true);
        addObject(new barra(),-1680,320,true);
        addObject(new Enemigo1(),-1700,528,true);
        addObject(new Enemigo1(),-350,528,true);
        addObject(new barra(),-347,320,true);
        addObject(new Enemigo1(),1450,260,true);
        addObject(new Enemigo1(),-347,260,true);
        addObject(new Pared(),-2005,515,true);
        addObject(new Pared(), -1300,515,true);
        addObject(new Pared(),-1000,515,true);
        addObject(new Enemigo1(),1700,528,true);
        
        //addObject(new Arma4(),-1600,538,true);
        
        addObject(new Enemigo1(),2390,528,true);
        addObject(new Enemigo1(),2000,528,true);
        addObject(new Pared(),1501,515,true);
        addObject(new Pared(),2000,515,true);
        addObject(new barra(),1500,450,true);
        addObject(new Arma2(),1580,538,true);
        addObject(new barra(),900,380,true);
        addObject(new Enemigo1(),700,260,true);


        
                
        addObject(new Enemigo2(),2500,528,true);
        addObject(new Puerta(), 2765,528,true);
        
        
        
    }
    void cargaNivel(){
        switch(nivel){
            case 2:
            addObject(new Pared(),-4300,515,true);
            addObject(new Enemigo1(),-4200, 528,true);
            addObject(new Enemigo2(),-4100, 528,true);
            addObject(new Enemigo2(),-4000,528,true);
            addObject(new Pared(), -3900,515,true);
            addObject(new barra(),-3900,400,true);
            addObject(new Enemigo1(),-3900,350,true);
            addObject(new Enemigo2(),-3800,528,true);
            addObject(new barra(), -3700,450,true);
            addObject(new Arma3(), -3750,430,true);
            
            // addObject(new Arma4(),-3600,538,true);
            
            addObject(new Enemigo2(),-3500,528,true);
            addObject(new Enemigo2(),-3500,350,true);
            addObject(new barra(),-3500,400,true);
            addObject(new Enemigo2(), -3380,528,true);
            addObject(new oneup(), -3200, 530,true);
            addObject(new Pared(),-3100,515,true);
            addObject(new Enemigo1(),-2900,528,true);
            addObject(new Enemigo1(),-2800,528,true);
            addObject(new Enemigo1(),-2700,528,true);
            addObject(new barra(),-2700,400,true);
            addObject(new Enemigo1(),-2700,350,true);
            
             //addObject(new Arma4(),-2600,538,true);
            
            addObject(new Arma2(),-2600,530,true);
            addObject(new Enemigo1(),-2450,528,true);
            addObject(new Enemigo2(),-2300,528,true);
            addObject(new Enemigo2(),-2000,528,true);
            addObject(new barra(),-1900,400,true);
            addObject(new Enemigo3(),-1890,350,true);
            addObject(new Enemigo2(),-1800,528,true);
            addObject(new Pared(),-1500,515,true);
            addObject(new Enemigo1(),-1300,528,true);
            addObject(new Enemigo2(),-1100,528,true);
            addObject(new Enemigo1(),-1000,528,true);
            addObject(new oneup(),-900,530,true);
            addObject(new Pared(), -800,515,true);
            addObject(new barra(), -600,400,true);
            addObject(new Enemigo3(),-550,350,true);
            addObject(new Enemigo3(),-500,528,true);
            addObject(new Enemigo3(),-300,528,true);
            addObject(new Enemigo2(),-100,528,true);
            
            addObject(new Enemigo3(),100,528,true);
            addObject(new Enemigo1(),200,528,true);
            addObject(new Enemigo3(),450,528,true);
            addObject(new Puerta(),550,528,true);
            
            break;
            
            case 3:
            addObject(new Pared(),-4300,515,true);     
            addObject(new Enemigo1(), -4400,528,true);
            addObject(new Enemigo2(),-4300,528,true);
            addObject(new Pared(),-4000,515,true);
            addObject(new Enemigo3(),-3700,528,true);
            addObject(new Enemigo2(),-3300,528,true);
            addObject(new Enemigo3(),-3200,528,true);            
            addObject(new Enemigo3(),-2500,528,true);
            addObject(new Enemigo2(),-2400, 528,true);
            //addObject(new Arma4(),-2100,538,true);
            addObject(new Arma3(),-2100,538,true);
            addObject(new Pared(),-1900,515,true);
            addObject(new oneup(), -1800,350,true);
            addObject(new barra(), -1800,400, true);
            addObject(new barra(),-1500,400,true);
            addObject(new Arma3(),-1400, 350,true);
            addObject(new barra(), -1400,400, true);
            addObject(new Enemigo2(),-1500, 350,true);
            addObject(new Enemigo2(),-1330,528,true);
            addObject(new Enemigo3(),-1200,528,true);
            addObject(new Enemigo3(),-1000,528,true);            
            addObject(new Enemigo1(),-700,528,true);
            addObject(new barra(),-700,400,true);
            addObject(new Enemigo4(),-700,350,true);
            addObject(new Pared(),-500,515,true);
            addObject(new Enemigo2(),-300,528,true);
            addObject(new Enemigo2(),-300,528,true);
            
            addObject(new Arma4(),-200,538,true);
            
            addObject(new barra(),100,450,true);
            addObject(new Enemigo3(),100,410,true);
            addObject(new Enemigo3(),100,528,true);
            addObject(new Enemigo2(),200,528,true);
            addObject(new barra(),200,400,true);            
            addObject(new Enemigo4(),200,350,true);
            addObject(new oneup(), 250,350,true);
            addObject(new Enemigo4(),200,350,true);
            addObject(new barra(),300,400,true);            
            addObject(new Enemigo4(),300,528,true);
            addObject(new Enemigo4(),300,528,true);
            
            addObject(new Puerta(),550,528,true);
            break;
            
            
                      
            case 4:
             addObject(new Arma4(),-4300,538,true);             
            addObject(new Pared(),-4200,515,true);
            addObject(new Enemigo1(),-4000,528,true);
            addObject(new Enemigo1(),-4200,528,true);
            addObject(new Enemigo1(),-4000,528,true);                    
            addObject(new barra(), -4000,400, true);
            addObject(new oneup(),-4000,350,true);
            addObject(new Pared(),-3900,515,true);
            
            //addObject(new Arma4(),-3800,538,true);
            
            addObject(new Enemigo2(),-3500,528,true);
            addObject(new Enemigo2(),-3400,528,true);
            addObject(new Enemigo2(),-3300,528,true);
            addObject(new Enemigo2(),-3200,528,true);
            addObject(new Enemigo2(),-3100,528,true);
            addObject(new Enemigo2(),-3000,528,true);
            addObject(new Enemigo2(),-2900,528,true);
            addObject(new Arma4(),-2850,435,true);
            addObject(new Enemigo1(),-2500,528,true);
            addObject(new Enemigo2(),-2400,528,true);
            addObject(new Enemigo3(),-2300,528,true);
            addObject(new Enemigo4(),-2200,528,true);
            addObject(new Pared(),-2100,515,true);
            addObject(new oneup(),-2050,530,true);
            
            
            addObject(new barra(), -2000,400, true);
            addObject(new Enemigo3(),-2000,528,true);
            addObject(new Enemigo3(),-1900,528,true);
            addObject(new Enemigo3(),-1800,528,true);
            addObject(new Enemigo3(),-1700,528,true);
            addObject(new oneup(), -1800,350,true);
            addObject(new Pared(),-600,515,true);
            addObject(new barra(), -1800,400, true);
            addObject(new Enemigo4(),-400,528,true);
            addObject(new Enemigo4(),-200,528,true);
            
            addObject(new Enemigo4(),0,528,true);
            addObject(new barra(), 0,400, true);
            addObject(new Enemigo4(),0,350,true);
            addObject(new Enemigo4(), 100,528,true);
            addObject(new Enemigo4(),300,528,true);
            
            
            addObject(new Puerta(),550,528,true);
            break;
        
        
        }
    
    }
    void EliminarTodo(){
        removeObjects(getObjects(Puerta.class));
        removeObjects(getObjects(Pared.class));
        removeObjects(getObjects(barra.class));
        removeObjects(getObjects(Enemigo1.class));
        removeObjects(getObjects(Enemigo2.class));
        removeObjects(getObjects(Enemigo3.class));
        removeObjects(getObjects(Enemigo4.class));
        removeObjects(getObjects(bullete1.class));
        removeObjects(getObjects(bullet1.class));
        removeObjects(getObjects(bulletG.class));
        removeObjects(getObjects(bulletGE.class));
        removeObjects(getObjects(Arma1.class));
        removeObjects(getObjects(Arma2.class));
        removeObjects(getObjects(Arma3.class));
        removeObjects(getObjects(Arma4.class));
        removeObjects(getObjects(oneup.class));
        
    }
    public void setjugx(int x){
        jugX=x;
        
    }
    public int getjugx(){
        return jugX;
        
    }
    public void setNivel(int x){
        nivel=x;
        
    }
    public int getNivel(){
        return nivel;
        
    }

    
}
